import 'package:flutter/material.dart';
import 'package:ost_flutter_module/common/adapt.dart';
import 'package:ost_flutter_module/common/color.dart';
import 'package:ost_flutter_module/common/styles.dart';

class GListTile extends StatelessWidget {
  final double leadingWidth;
  final Widget leading, title, trailing, enableWidget;
  final String text, trailText;
  final bool enable;
  final EdgeInsetsGeometry padding;
  final dynamic entity;
  final Function(dynamic) onTap;

  const GListTile({
    Key key,
    this.leading,
    this.title,
    this.trailing,
    this.text = '',
    this.trailText = '',
    this.enable = false,
    this.enableWidget,
    this.leadingWidth,
    this.entity,
    this.onTap,
    this.padding,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Ink(
      child: Material(
        color: Colors.transparent,
        child: InkWell(
          onTap: enable
              ? () {
                  onTap(entity);
                }
              : null,
          child: Padding(
            padding: padding ?? EdgeInsets.all(Adapt.px(10)),
            child: Row(
              children: [
                leadingWidth != null
                    ? SizedBox(
                        width: Adapt.px(leadingWidth),
                        child: leading ?? Container(),
                      )
                    : leading ?? Container(),
                SizedBox(width: Adapt.px(10)),
                title ?? Text(text, style: TextStyles.titleStyle),
                SizedBox(width: Adapt.px(8)),
                Expanded(
                    child: trailing != null
                        ? trailing
                        : trailText.isNotEmpty
                            ? Text(
                                trailText,
                                style: TextStyles.titleStyle,
                                textAlign: TextAlign.end,
                              )
                            : Container()),
                enableWidget != null
                    ? enableWidget
                    : enable
                        ? Icon(Icons.navigate_next_rounded, color: color999999)
                        : Container(),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
